package com.wz.project.sap.PYPK.controller;

import java.util.Date;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.sap.PYPK.domain.ZflWmsPyPk;
import com.wz.project.sap.PYPK.service.IZflWmsPyPkService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 库存盘盈盘亏Controller
 * 
 * @author wz
 * @date 2022-09-14
 */
@Controller
@RequestMapping("/PYPK/PYPK")
public class ZflWmsPyPkController extends BaseController
{
    private String prefix = "PYPK/PYPK";

    @Autowired
    private IZflWmsPyPkService zflWmsPyPkService;

//    @RequiresPermissions("PYPK:PYPK:view")
    @GetMapping()
    public String PYPK()
    {
        return prefix + "/PYPK";
    }

    /**
     * 查询库存盘盈盘亏列表
     */
//    @RequiresPermissions("PYPK:PYPK:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZflWmsPyPk zflWmsPyPk)
    {
        startPage();
        List<ZflWmsPyPk> list = zflWmsPyPkService.selectZflWmsPyPkList(zflWmsPyPk);
        return getDataTable(list);
    }

    /**
     * 导出库存盘盈盘亏列表
     */
//    @RequiresPermissions("PYPK:PYPK:export")
    @Log(title = "库存盘盈盘亏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZflWmsPyPk zflWmsPyPk)
    {
        List<ZflWmsPyPk> list = zflWmsPyPkService.selectZflWmsPyPkList(zflWmsPyPk);
        ExcelUtil<ZflWmsPyPk> util = new ExcelUtil<ZflWmsPyPk>(ZflWmsPyPk.class);
        return util.exportExcel(list, "PYPK");
    }

    /**
     * 新增库存盘盈盘亏
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存库存盘盈盘亏
     */
    @RequiresPermissions("PYPK:PYPK:add")
    @Log(title = "库存盘盈盘亏", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZflWmsPyPk zflWmsPyPk)
    {
        return toAjax(zflWmsPyPkService.insertZflWmsPyPk(zflWmsPyPk));
    }

    /**
     * 修改库存盘盈盘亏
     */
    @GetMapping("/edit/{BLDAT}")
    public String edit(@PathVariable("BLDAT") Date BLDAT, ModelMap mmap)
    {
        ZflWmsPyPk zflWmsPyPk = zflWmsPyPkService.selectZflWmsPyPkById(BLDAT);
        mmap.put("zflWmsPyPk", zflWmsPyPk);
        return prefix + "/edit";
    }

    /**
     * 修改保存库存盘盈盘亏
     */
    @RequiresPermissions("PYPK:PYPK:edit")
    @Log(title = "库存盘盈盘亏", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZflWmsPyPk zflWmsPyPk)
    {
        return toAjax(zflWmsPyPkService.updateZflWmsPyPk(zflWmsPyPk));
    }

    /**
     * 删除库存盘盈盘亏
     */
    @RequiresPermissions("PYPK:PYPK:remove")
    @Log(title = "库存盘盈盘亏", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zflWmsPyPkService.deleteZflWmsPyPkByIds(ids));
    }
}
